package cn.linkai.star.graph.core.service.impl;

import cn.linkai.star.graph.core.service.WsNoticeService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service;


@Service
public class WsNoticeServiceImpl implements WsNoticeService {

    @Autowired
    private SimpMessagingTemplate simpMessagingTemplate;

    public static final String COMFYUI_QUERY_TOPIC = "/topic/messages";

    /**
     * 发送消息给指定用户
     * @param wsClientId 客户端 id
     * @param message 消息内容
     */
    @Override
    public void sendToUser(String wsClientId, String message) {
        simpMessagingTemplate.convertAndSendToUser (wsClientId,COMFYUI_QUERY_TOPIC,message);
    }

    /**
     * 发送消息给所有用户
     * @param message 消息内容
     */
    @Override
    public void sendToAll(String message) {
        simpMessagingTemplate.convertAndSend (COMFYUI_QUERY_TOPIC,message);
    }
}
